package com.qx.chat.akka;

import org.apache.log4j.Logger;

import akka.actor.ActorSystem;


/**
 * Akka System 启动类
 * @author cyf
 *
 */
public class AkkaSystem {

	private Logger logger = Logger.getLogger(AkkaSystem.class);


	/**
	 * 默认的Akka System Name
	 */
	public static final String DEFAULT_SYSTEM_NAME = "AkkaSystem";


	private ActorSystem system;

	/**
	 * 同步线程
	 */
	private Thread thread = new Thread();

	/**
	 * 启动方法，通过进程同步，将加入集群变成同步
	 */
	public void start() {
		thread.start();
		logger.info(">>>>> 启动Akka System 。。。");

		system = ActorSystem.create(DEFAULT_SYSTEM_NAME);
		
		Qxchat.getInstance().setAkkaSystem(system);
	}

	/**
	 * 停止AkkaSystem，
	 */
	@SuppressWarnings("deprecation")
	public void close() {
		system.shutdown();
	}

	public ActorSystem getSystem() {
		return system;
	}

}
